﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;

namespace DTC.Validations
{
    class IntegerValidation : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if (value is string)
            {
                string input = value as string;
                if (input.Length == 0)
                    return new ValidationResult(true, null);
                int tmp;
                if (Int32.TryParse(input, out tmp))
                    return new ValidationResult(true, null);
                else return new ValidationResult(false, "Пожалуста укажите целое число");
            }
            else return new ValidationResult(false, "Произошла неизвестная ошибка");
        }
    }
}
